package proxy2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 代理类
 */
public class ProxyObject  implements InvocationHandler{
    //要代理的真实对象
    private Object target;
    public ProxyObject(Subject target){
        this.target=target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("proxy"+proxy.getClass().getName());
        System.out.println("before...");
        method.invoke(target,args);
        System.out.println("after...");
        return null;
    }
}
